<?php $this->load->view('layout/header');?>
<div class="supplier-content-page">
    <div class="product-test-h5">
        <ul class="breadcrumb">
            <li><a href="javascript:;">我的账户</a></li>
            <li class="active"><a href="<?php echo site_url('accountinfo/securitySettings')?>">安全设置</a></li>
            <li>修改分销商</li>
        </ul>
        <?php echo execute_alert_message();?>
        <div class="order-right">
            <div class="pass-frame">
                <ul class="pass-mody clearfix">
                    <li>
                        <span class="pass-hr"></span>
                        <i class="iconfont">&#xe607;</i>
                        <p>验证身份</p>
                    </li>
                    <li class="active">
                        <span class="pass-hr"></span>
                        <i class="iconfont">&#xe605;</i>
                        <p>修改分销商</p>
                    </li>
                    <li>
                        <span class="pass-hr"></span>
                        <i class="iconfont">&#xe606;</i>
                        <p>完成</p>
                    </li>
                </ul>
                <form class="pass-form form-horizontal" id="sellerform" action="<?php echo site_url('validate/modifySellerSuccess'); ?>" method="post" >
                    <div class="form-group">
                        <label class="col-sm-1 control-label">分销商</label>
                        <div class="col-sm-6 controls">
                          <input type="text" class="form-control queryid" placeholder="分销商用户名或手机号" value="<?php if (isset($seller_name)): echo $seller_name;endif;?>" />
                          <input type="hidden" name="seller_id" value="<?php if (isset($seller_id)): echo $seller_id;endif;?>"/>
                        </div>
                    </div>
                    <button type="submit" class="pass-submit">确定</button>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('layout/footer');?>
<script type="text/javascript">
$(function(){
    $('form#sellerform').submit(function(){
        return false;
    }).validate({
         submitHandler:function(form) {
        	 var obj = $('button[type=submit]');
             $.ajax({
                type:'post',
                url:hostUrl()+'/validate/modifySellerSuccess',
                data:$('form#sellerform').serialize(),
                async:true,
                dataType:'json',
                beforeSend:function(){
                    obj.text('正在保存...').attr('disabled', true); 
                },
                success:function(data) {
                    if (data.status) {
                        layerMessages(data.status);
                        setTimeout(function(){
                            location.href = data.msg;
                        }, 2000);
                    } else {
                        layerMessages(data.status, data.msg);
                        obj.text('重新保存').removeAttr('disabled');
                    }
                }
             })
        }
    });
    $('.queryid').change(function(){
        $.ajax({
            type:'post',
            url:hostUrl()+'/validate/ajaxQueryId',
            data:{namephone:$(this).val()},
            async:false,
            dataType:'json',
            success:function(data) {
                if (data.status) {
                    $("[name='seller_id']").val(data.data.id);
                } else {
                    $("[name='seller_id']").val(0);
                    layerMessages(data.status, data.msg);
                }
            }
         });
    });
});
</script>